/**
   @file sys_usw_scl.h

   @date 2017-01-23

   @version v1.0

   The file contains all scl APIs of sys layer

 */
 #ifndef _SYS_USW_SCL_NEW_H
#define _SYS_USW_SCL_NEW_H

#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
*
* Header Files
*
****************************************************************************/
#include "sal.h"

#include "ctc_error.h"
#include "ctc_hash.h"
#include "ctc_spool.h"
#include "ctc_vector.h"
#include "ctc_const.h"
#include "ctc_vlan.h"
#include "ctc_qos.h"
#include "ctc_linklist.h"
#include "ctc_debug.h"

#include "ctc_scl.h"

#include "sys_usw_scl_api.h"
#include "sys_usw_chip.h"
#include "sys_usw_fpa.h"
#include "sys_usw_acl_api.h"
#include "drv_api.h"
#include "sys_usw_overlay_tunnel.h"
#include "sys_usw_xdata_api.h"


/****************************************************************************
 *
 * Defines and Macros
 *
 *****************************************************************************/
#define SYS_SCL_MAX_HASH_SEL_PROFILE    16
#define SYS_SCL_INVALID_AD_INDEX 0xFFFFF


#define SYS_SCL_ING_TCAM_NUM    4
#define SYS_SCL_EGR_TCAM_NUM    2
#define SCL_TCAM_NUM            (SYS_SCL_ING_TCAM_NUM + SYS_SCL_EGR_TCAM_NUM)
#define SCL_ENCODE_BLOCK_ID(dir, prio)    (dir == CTC_INGRESS ? prio : prio + SYS_SCL_ING_TCAM_NUM)
#define SYS_SCL_ENCODE_DEF_ENTRY_INDEX(scl_id, lport, action_type)  ((DRV_FROM_AT(lchip)?((action_type<<10)|(scl_id<<9)):((action_type<<9)|(scl_id<<8)))|(lport))
#define SYS_SCL_ENCODE_DEF_ENTRY_ID(scl_id, lport, action_type)  ((scl_id)<< 24 | (lport) << 8 | (action_type))
#define SYS_SCL_MAP_DRV_AD_INDEX(index, step)  ((1 == (step)) ? (index) : ((index) / 2))
#define SYS_SCL_USERID_ROUTER_MAC_HIT_BASE       24
#define SYS_SCL_TEMP_USERID_BASE                 16
#define SYS_SCL_TEMP_USERID(ds, offset)     ((uint32*)(ds)+SYS_SCL_TEMP_USERID_BASE+((offset)<<1))

#define SYS_SCL_CHK_UNION(gtype, gtype_value)    (gtype != gtype_value && gtype != SYS_AD_UNION_G_NA )
#define SYS_SCL_IS_INNER_ENTRY(entry_id) ((entry_id >= SYS_SCL_MIN_INNER_ENTRY_ID) ? 1:0)

#define SYS_USW_SCL_REMOVE_ACTION_CHK(is_add, pe, pAction, old_type, new_type) \
    if(!is_add && (pe->u.temp_entry->temp_ad.fwd_type == old_type) && (pAction->type == new_type))\
    {\
        CTC_ERROR_RETURN(CTC_E_INVALID_CONFIG);\
    }

#define SYS_USW_SCL_SET_BMP(bmp, bit, is_set) \
        do{\
            if(is_set)\
                CTC_BMP_SET(bmp, bit);\
            else\
                CTC_BMP_UNSET(bmp, bit);\
        }while(0)
    
    
#define SYS_USW_SCL_GPORT_IS_LOCAL(lchip,gport) \
         (CTC_IS_LINKAGG_PORT(gport) || !SYS_GCHIP_IS_REMOTE(lchip,SYS_MAP_CTC_GPORT_TO_GCHIP(gport)))
    
#define SYS_SCL_VEDIT_PRFID_SVLAN_CLASS                   3
#define SYS_SCL_VEDIT_PRFID_SVLAN_SCOS_CLASS              2
#define SYS_SCL_VEDIT_PRFID_SVLAN_DOMAIN                  1
    
#define SYS_SCL_TRAVERSE_ALL                              0
#define SYS_SCL_TRAVERSE_BY_PORT                          1
#define SYS_SCL_TRAVERSE_BY_GROUP                         2
    
#define SYS_SCL_MIN_INNER_ENTRY_ID      0x80000000 /* min sdk entry id*/
#define SYS_SCL_MAX_INNER_ENTRY_ID      0xFFFFFFFF /* max sdk entry id*/

#define SYS_SCL_GROUP_LIST_NUM                         3
#define SYS_SCL_GROUP_ID_MAX                           0xFFFFFFFF

#define SCL_KEY_USW_SIZE_80             12
#define SCL_KEY_USW_SIZE_160            24
#define SCL_KEY_USW_SIZE_320            48
#define SCL_KEY_USW_SIZE_640            96
#define SCL_KEY_USW_SIZE_DEFAULT_PORT   4

#define SYS_SCL_XKEY_TYPE_BASE  CTC_SCL_KEY_NUM

#define SYS_SCL_FWD_DISCARD            1
#define SYS_SCL_FWD_REDIRECT           2
#define SYS_SCL_FWD_REDIRECT_PORT      3

#define SYS_SCL_ENTRY_HASH_NUM       1

#define SYS_SCL_CHECK_OUTER_GROUP_ID(gid, unlock)        \
    {                                            \
        if ((gid) >= CTC_SCL_GROUP_ID_RSV_MAX || ((gid) > CTC_SCL_GROUP_ID_MAX_NORMAL && (gid) < CTC_SCL_GROUP_ID_HASH_PORT)) { \
            if((unlock)) {                      \
                sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); }\
            return CTC_E_BADID; }         \
    }

#define SYS_SCL_CHECK_GROUP_TYPE(type)        \
    {                                         \
        if (type >= CTC_SCL_GROUP_TYPE_MAX) { \
            return CTC_E_INVALID_PARAM; }    \
    }

#define SYS_SCL_CHECK_GROUP_PRIO(priority)           \
    {                                                \
        if (priority >= MCHIP_CAP(SYS_CAP_SCL_IGS_TCAM_NUM)) { \
            return CTC_E_INVALID_PARAM; }       \
    }

#define SYS_SCL_CHECK_ENTRY_ID(eid, inner, unlock)            \
    {                                          \
        if(!inner)                          \
        {                                   \
            if (eid > CTC_SCL_MAX_USER_ENTRY_ID) { \
            if((unlock))                    \
            {                               \
                sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); \
            }                               \
            return CTC_E_INVALID_PARAM; }   \
        }                                   \
        else                                \
        {                                   \
            if (eid <= CTC_SCL_MAX_USER_ENTRY_ID) { \
            if((unlock))                    \
            {                               \
                sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); \
            }                               \
            return CTC_E_INVALID_PARAM; }   \
        }                                   \
    }                                       \

#define SYS_SCL_CHECK_ENTRY_PRIO(priority)  \
    {                                          \
        if (priority > FPA_PRIORITY_HIGHEST) { \
            return CTC_E_INVALID_PARAM; }      \
    }

#define SYS_SCL_CHECK_GROUP_UNEXIST(pg, unlock)     \
    {                                       \
        if (!pg)                            \
        {                                   \
            if((unlock))                    \
            {                               \
                sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); \
            }                               \
            return CTC_E_NOT_EXIST; \
        }                                   \
    }

#define SYS_SCL_SET_MAC_HIGH(dest_h, src)    \
    {                                        \
        dest_h = ((src[0] << 8) | (src[1])); \
    }

#define SYS_SCL_SET_MAC_LOW(dest_l, src)                                       \
    {                                                                          \
        dest_l = ((src[2] << 24) | (src[3] << 16) | (src[4] << 8) | (src[5])); \
    }

#define SYS_SCL_LOCK(lchip) \
    if(p_usw_scl_master[lchip]->mutex) sal_mutex_lock(p_usw_scl_master[lchip]->mutex)

#define SYS_SCL_UNLOCK(lchip) \
    if(p_usw_scl_master[lchip]->mutex) sal_mutex_unlock(p_usw_scl_master[lchip]->mutex)

#define CTC_USW_RETURN_SCL_UNLOCK(op) \
    do \
    { \
        sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); \
        return (op); \
    } while (0)

#define CTC_USW_ERROR_RETURN_SCL_UNLOCK(op) \
    do \
    { \
        int32 rv = (op); \
        if (rv < 0) \
        { \
            sal_mutex_unlock(p_usw_scl_master[lchip]->mutex); \
            return rv; \
        } \
    } while (0)

#define SYS_SCL_INIT_CHECK()         \
    {                                \
        LCHIP_CHECK(lchip);          \
        if (!p_usw_scl_master[lchip]) {           \
            return CTC_E_NOT_INIT; } \
    }

#define SCL_ENTRY_IS_TCAM(type)   (SYS_SCL_KEY_TCAM_END >= (type))

#define SCL_ENTRY_IS_XKEY(type)    \
    (type >= SYS_SCL_XKEY_TYPE_BASE)

#define SYS_SCL_CHECK_MODE_TYPE(type)  \
    {                                          \
        if (type >= 2) { \
            return CTC_E_INVALID_PARAM; }      \
    }

#define SYS_SCL_ENCODE_XKEY_FPA_SIZE(p_flexed_key, pe, fpa_size) \
    {\
        fpa_size = p_usw_scl_master[lchip]->fpa_size[pe->key_type];\
        if (p_flexed_key && p_flexed_key->is_xkey && !p_flexed_key->is_replace)\
        {\
            fpa_size = fpa_size+1;\
        }\
    }

#define SYS_SCL_DBG_OUT(level, FMT, ...)    CTC_DEBUG_OUT(scl, scl, SCL_SYS, level, FMT, ## __VA_ARGS__)


#define SET_VLANXC   SetDsEgressXcOamDoubleVlanPortHashKey
#define GET_VLANXC   GetDsEgressXcOamDoubleVlanPortHashKey

#define SYS_SCL_GET_STEP(fpa_size)  \
        (((fpa_size)==CTC_FPA_KEY_SIZE_80)?1:(((fpa_size)==CTC_FPA_KEY_SIZE_160)?2:\
                (((fpa_size)==CTC_FPA_KEY_SIZE_320)?4:(((fpa_size)==CTC_FPA_KEY_SIZE_640)?8:1))))

#define SCL_INNER_ENTRY_ID(eid)          ((eid >= SYS_SCL_MIN_INNER_ENTRY_ID) && (eid <= SYS_SCL_MAX_INNER_ENTRY_ID))

/*below define must be used without g0 in the union*/
#define SYS_CHK_UN_BMP_HW(gtype_value,tab,un_id,ds)   \
    do{\
        uint8  utype = 0;\
        uint8  is_valid = 0;\
        uint32 fld_data[4] = {0};\
        utype = Get##tab(V, u##un_id##Type_f, ds);\
        Get##tab(A, u##un_id##_data_f, ds, fld_data);\
        is_valid = ((utype+SYS_AD_UNION_G_1)==gtype_value)? 1: 0;\
        is_valid |= ((utype == 0) && (!fld_data[0] && !fld_data[1] && !fld_data[2] && !fld_data[3]))? 1: 0;\
        if (!is_valid)  CTC_ERROR_RETURN(CTC_E_PARAM_CONFLICT);\
    }while(0)
/*below define must be used without g0 in the union*/
#define SYS_SET_UN_TYPE_HW(gtype_value,tab,un_id,ds, is_add) \
    do{\
        uint8  utype = 0;\
        uint32 fld_data[4] = {0};\
        if(is_add)  {\
            utype = gtype_value - SYS_AD_UNION_G_1;\
        }else {\
            Get##tab(A, u##un_id##_data_f, ds, fld_data);\
            utype = (!fld_data[0] && !fld_data[1] && !fld_data[2] && !fld_data[3])? 0: (gtype_value - SYS_AD_UNION_G_1);\
        }\
        Set##tab(V, u##un_id##Type_f, ds, utype);\
    }while(0)

enum sys_scl_userid_bmp_e
{
    SYS_SCL_USERID_BMP_FWD,
    SYS_SCL_USERID_BMP_VLAN_XLATE,
    SYS_SCL_USERID_BMP_LOGIC_PORT,
    SYS_SCL_USERID_BMP_FLOW,
    SYS_SCL_USERID_BMP_PORT_EXTENDER,
    SYS_SCL_USERID_BMP_BINDING,
    SYS_SCL_USERID_BMP_U1_G1,
    SYS_SCL_USERID_BMP_RSV,
    SYS_SCL_USERID_BMP_MAX
};
typedef enum sys_scl_userid_bmp_e sys_scl_userid_bmp_t;

/* field type for show */
enum sys_scl_show_field_key_type_e
{
    SYS_SCL_SHOW_FIELD_KEY_PORT,
    SYS_SCL_SHOW_FIELD_KEY_DST_GPORT,
    SYS_SCL_SHOW_FIELD_KEY_CVLAN_ID,
    SYS_SCL_SHOW_FIELD_KEY_SVLAN_ID,
    SYS_SCL_SHOW_FIELD_KEY_MAC_SA,
    SYS_SCL_SHOW_FIELD_KEY_MAC_DA,
    SYS_SCL_SHOW_FIELD_KEY_IP_SA,
    SYS_SCL_SHOW_FIELD_KEY_IP_DA,
    SYS_SCL_SHOW_FIELD_KEY_IPV6_SA,
    SYS_SCL_SHOW_FIELD_KEY_IPV6_DA,
    SYS_SCL_SHOW_FIELD_KEY_L4_SRC_PORT,
    SYS_SCL_SHOW_FIELD_KEY_L4_DST_PORT,
    SYS_SCL_SHOW_FIELD_KEY_GRE_KEY,
    SYS_SCL_SHOW_FIELD_KEY_VN_ID,
    SYS_SCL_SHOW_FIELD_KEY_MPLS_LABEL0,
    SYS_SCL_SHOW_FIELD_KEY_MPLS_LABEL1,
    SYS_SCL_SHOW_FIELD_KEY_MPLS_LABEL2,
    SYS_SCL_SHOW_FIELD_KEY_L4_TYPE,
    SYS_SCL_SHOW_FIELD_KEY_FWD_TYPE,
    SYS_SCL_SHOW_FIELD_KEY_X_UDF,
    SYS_SCL_SHOW_FIELD_KEY_X_SVLAN_RANGE,
    SYS_SCL_SHOW_FIELD_KEY_X_CVLAN_RANGE,
    SYS_SCL_SHOW_FIELD_KEY_X_L4_USER_TYPE,
    SYS_SCL_SHOW_FIELD_KEY_X_IP_HDR_ERROR,
    SYS_SCL_SHOW_FIELD_KEY_X_L2_TYPE,
    SYS_SCL_SHOW_FIELD_KEY_X_L3_TYPE,
    SYS_SCL_SHOW_FIELD_KEY_X_VLAN_NUM,
    SYS_SCL_SHOW_FIELD_KEY_X_IP_FRAG,
    SYS_SCL_SHOW_FIELD_KEY_X_DST_CID,
    SYS_SCL_SHOW_FIELD_KEY_X_XDATA,
    SYS_SCL_SHOW_FIELD_KEY_NUM
};
typedef enum sys_scl_show_field_key_type_e sys_scl_show_field_key_type_t;

typedef enum sys_scl_xdata_chunk_e
{
    SYS_SCL_XDATA_IGS_CHUNK0_NIBBLE4    = (1U << 0),
    SYS_SCL_XDATA_IGS_CHUNK1_NIBBLE3_0  = (1U << 1),
    SYS_SCL_XDATA_IGS_CHUNK2_BYTE0      = (1U << 2),
    SYS_SCL_XDATA_IGS_CHUNK2_BYTE1      = (1U << 3),
    SYS_SCL_XDATA_IGS_CHUNK3_WORD0      = (1U << 4),
    SYS_SCL_XDATA_IGS_CHUNK3_WORD0_UDF  = (1U << 5),
    SYS_SCL_XDATA_IGS_CHUNK4_WORD1      = (1U << 6),

    SYS_SCL_XDATA_EGS_CHUNK0_NIBBLE4        = (1U << 7),
    SYS_SCL_XDATA_EGS_CHUNK1_NIBBLE3_0      = (1U << 8),
    SYS_SCL_XDATA_EGS_CHUNK2_BYTE1_0        = (1U << 9),
    SYS_SCL_XDATA_EGS_CHUNK3_WORD1          = (1U << 10)
}sys_scl_xdata_chunk_t;

typedef struct sys_scl_sw_entry_s
{
    ctc_list_pointer_node_t         head;
    uint32 entry_id;
    uint32 direction            : 2,
           key_type             : 8,
           action_type          : 4,
           resolve_conflict     : 1,
           uninstall            : 1,
           hash_valid           : 1,
           key_exist            : 1,
           key_conflict         : 1,
           is_default           : 1,
           is_pending           : 1,
           is_half              : 1,
           l3_type              : 4,
           l4_type              : 4,
           group_priority       : 2;

    uint32 vrange_gid           : 6,
           hash_field_sel_id    : 4,
           is_xkey              : 1,
           is_buffer            : 1,
           key_index            : 20;

    uint32 key_bmp;
    
    union
    {
        void* ad;
        /* buffer */
        sys_scl_sw_temp_entry_t* temp_entry;
    }u;
    uint32 group_id;
    uint32 action_bmp[CTC_B2W_SIZE(SYS_SCL_FIELD_ACTION_TYPE_MAX)];
}sys_scl_sw_entry_t;


typedef struct sys_scl_sw_entry_tcam_s
{
   sys_scl_sw_entry_t he;/* hash entry*/
   uint32  l2_type              : 4,
           l4_user_type         : 4,
           mac_key_vlan_mode    : 2,
           mac_key_macda_mode   : 2,
           key_l4_port_mode     : 2,
           ether_type_index     : 8,
           range_bitmap         : 16,
           ether_type_valid     : 1,
           rsv0                 : 1;
}sys_scl_sw_entry_tcam_t;

typedef struct
{
    ctc_fpa_entry_t     fpae;
    sys_scl_sw_entry_t* entry;
}sys_scl_sw_tcam_entry_t;


typedef struct
{
    uint32  key_index;
    uint8   action_type;
    uint8   scl_id;
    uint32  calc_key_len[0];

    uint32 entry_id;

}sys_scl_hash_key_entry_t;


typedef struct
{
    ctc_fpa_block_t fpab;
}sys_scl_sw_block_t;

typedef struct
{
    /* key */
    uint32 key[SYS_SCL_MAX_KEY_SIZE_IN_WORD];
    uint32 mask[SYS_SCL_MAX_KEY_SIZE_IN_WORD];
    uint8  scl_id;
    uint8  rsv[3];
    /* ad */
    sys_scl_sw_entry_t* p_entry;
}sys_scl_tcam_entry_key_t;

typedef struct sys_scl_kset_s {
    uint32 w[CTC_B2W_SIZE(SYS_SCL_FIELD_KEY_NUM)];
} sys_scl_kset_t;

typedef int32 (* SYS_CB_SCL_BUILD_KEY_FUNC_T)(uint8 lchip, ctc_field_key_t* pKey, sys_scl_sw_entry_t* pe,uint8 is_add);
typedef int32 (* SYS_CB_SCL_GET_KEY_FUNC_T)(uint8 lchip, ctc_field_key_t* pKey, sys_scl_sw_entry_t* pe);
typedef int32 (* SYS_CB_SCL_BUILD_AD_FUNC_T)(uint8 lchip, ctc_scl_field_action_t* pAction, sys_scl_sw_entry_t* pe,uint8 is_add);
typedef int32 (* SYS_CB_SCL_GET_AD_FUNC_T)(uint8 lchip, ctc_scl_field_action_t* p_action, sys_scl_sw_entry_t* pe);

struct sys_scl_master_s
{
    ctc_hash_t         * group;                               /* Hash table save group by gid.*/
    ctc_fpa_t          * fpa;                                 /* Fast priority arrangement. no array. */
    ctc_hash_t         * entry;                               /* Hash table save hash|tcam entry by eid */
    ctc_hash_t         * hash_key_entry;                      /* Hash table save hash entry by key */
    ctc_hash_t         * tcam_entry_by_key;                   /* tcam table save tcam entry by key */
    ctc_spool_t        * ad_spool[SCL_HASH_NUM*SYS_SCL_SW_AD_TYPE_IGS_MAX];                            /* Share pool save hash action */
    ctc_spool_t        * vlan_edit_spool;                     /* Share pool save vlan edit */
    ctc_spool_t        * acl_spool;                           /* Share pool save acl control */
    ctc_spool_t        * cethertype_spool;                    /* Share pool save compress ether type */
    sys_scl_sw_block_t* fpa_block;
    sal_mutex_t        * mutex;
    SYS_CB_SCL_BUILD_KEY_FUNC_T build_key_func[SYS_SCL_KEY_NUM ];
    SYS_CB_SCL_GET_KEY_FUNC_T   get_key_func[SYS_SCL_KEY_NUM ];
    SYS_CB_SCL_BUILD_AD_FUNC_T build_ad_func[SYS_SCL_ACTION_NUM];
    SYS_CB_SCL_GET_AD_FUNC_T get_ad_func[SYS_SCL_ACTION_NUM];
    uint8              opf_type_vlan_edit;
    uint8              opf_type_entry_id;
    uint8              opf_type_flow_acl_profile;
    uint8              opf_type_tunnel_acl_profile;
    uint8              fpa_size[SYS_SCL_KEY_NUM];
    uint8              key_size[SYS_SCL_KEY_NUM];
    uint32             igs_default_base[SCL_HASH_NUM];
    uint32             tunnel_default_base[SCL_HASH_NUM];

    uint32             entry_count[SCL_HASH_NUM][SYS_SCL_ACTION_NUM];
    uint32             egs_entry_num[SCL_HASH_NUM]; /* for ergress hash resource without resolve conflict*/
    uint32             entry_num[SCL_HASH_NUM];/* for ingress hash resource without resolve conflict*/
    uint16             hash_sel_profile_count[SYS_SCL_MAX_HASH_SEL_PROFILE];
    uint8              hash_mode;                  /* 0:hash1 and hash2 use same index, 1:hash1 and hash2 use different index, 2:only one hash, default: 0 */
    /*uint8              slice_mode;*/                 /* 0:default, all slice use same resources, 1:per slice use private resources */
    ctc_vector_t       * default_entry;
    ctc_vector_t       * flex_key_vec;
    ctc_hash_t         *entry_pp_hash;  /* entry hash */
    sys_scl_kset_t***     kset_db;
};
typedef struct sys_scl_master_s   sys_scl_master_t;

extern sys_scl_master_t* p_usw_scl_master[CTC_MAX_LOCAL_CHIP_NUM_PP];

/*internal api*/

extern int32
sys_usw_scl_vlan_tag_op_translate(uint8 lchip, uint8 op_in, uint8* op_out, uint8* mode_out);

extern int32
sys_usw_scl_vlan_tag_op_untranslate(uint8 lchip, uint8 op_in, uint8 mo_in, uint8* op_out);

extern int32
sys_usw_scl_check_vlan_edit(uint8 lchip, ctc_scl_vlan_edit_t* vlan_edit, uint8* do_nothing);

extern int32
sys_usw_scl_get_acl_control_profile(uint8 lchip, uint8 is_tunnel, uint8* lkup_num, ctc_acl_property_t* p_acl_profile, void* p_buffer);

extern void*
sys_usw_scl_add_vlan_edit_action_profile(uint8 lchip,  ctc_scl_vlan_edit_t *vlan_edit, void* old_vlan_edit_profile);

extern int32
sys_usw_scl_remove_vlan_edit_action_profile(uint8 lchip, sys_scl_sp_vlan_edit_t* p_vlan_edit);

extern void*
sys_usw_scl_add_acl_control_profile(uint8 lchip,uint8 is_tunnel,uint8 lkup_num,ctc_acl_property_t acl_profile[CTC_MAX_ACL_LKUP_NUM],uint16 *profile_id);

extern int32
sys_usw_scl_remove_acl_control_profile(uint8 lchip, sys_scl_action_acl_t* p_acl_profile);

extern int32
_sys_usw_scl_create_group(uint8 lchip, uint32 group_id, ctc_scl_group_info_t* group_info, uint8 inner);

extern int32
_sys_usw_scl_get_default_action(uint8 lchip, sys_scl_default_action_t* p_default_action);

extern int32
_sys_usw_scl_get_group_by_gid(uint8 lchip, uint32 gid, sys_scl_sw_group_t** pg);

extern int32
_sys_usw_scl_init_build_key_and_action_cb(uint8 lchip);

extern int32
_sys_usw_scl_build_field_action_igs(uint8 lchip, ctc_scl_field_action_t* pAction, void* pe, uint8 is_add);

extern int32
_sys_usw_scl_build_field_action_userid(uint8 lchip, ctc_scl_field_action_t* pAction, sys_scl_sw_entry_t* pe, uint8 is_add);

extern int32
_sys_usw_scl_get_block_by_pe_fpa(uint8 lchip, ctc_fpa_entry_t* pe, ctc_fpa_block_t** pb);

extern int32
_sys_usw_scl_entry_move_hw_fpa(uint8 lchip, ctc_fpa_entry_t* pe, int32 tcam_idx_new);

extern int32
_sys_usw_scl_get_table_id(uint8 lchip, uint8 block_id, sys_scl_sw_entry_t* pe, uint32* key_id, uint32* act_id);

extern int32
_sys_usw_scl_get_index(uint8 lchip, uint32 key_id, sys_scl_sw_entry_t* pe, uint32* o_key_index, uint32* o_ad_index);

extern int32
_sys_usw_scl_get_slice_id(uint8 lchip, sys_scl_sw_entry_t* pe, uint8* p_slice_id);

extern int32
_sys_usw_scl_get_udf_key_share_type(uint8 lchip, uint8 scl_id, uint8* udf_share_type);

extern int32
_sys_usw_scl_wb_restor_range_info(void* bucket_data, void* user_data);

extern int32
_sys_usw_scl_get_compress_ipv6_addr(uint8 lchip, uint8 compress_mode, ipv6_addr_t ipv6, ipv6_addr_t ipv6_64);

extern int32
_sys_usw_scl_map_key_action_type(uint8 lchip, ctc_scl_entry_t* scl_entry, sys_scl_sw_entry_t* pe);

extern int32
_sys_usw_scl_mapping_ad(void * ad, sys_scl_sw_igs_ad_t * temp_ad, uint8 is2temp, uint8 is_igs_hash, uint8 dir);

extern    int32
_sys_usw_scl_offset_map_chunk(ctc_xdata_field_t* field, uint8 dir, uint32* chunk_bmp_o);

extern    int32 
_sys_usw_scl_check_xdata(uint8 lchip, sys_scl_sw_entry_t* pe, ctc_scl_field_action_t* pAction, void* ds, uint8 is_add, uint32* chunk_bmp_o );

#ifdef __cplusplus
}
#endif
#endif

